home *** CD-ROM | disk | FTP | other *** search
Modula Implementation | 1996-01-31 | 5.0 KB | 181 lines | [TEXT/3PRM] |
- implementation module events;
-
- import mac_types;
- import StdInt;
-
- // Event masks
-
- MDownMask :== 2;
- MUpMask :== 4;
- KeyDownMask :== 8;
- KeyUpMask :== 16;
- AutoKeyMask :== 2;
- UpdateMask :== 64;
- DiskMask :== 128;
- ActivMask :== 256;
- NetworkMask :== 1024;
- DriverMask :== 2048;
- OsMask :== -32768;
-
- // Device masks
-
- MouseMask :== 6; // MouseDown | MouseUp
- KeyboardMask :== 56; // KeyDown | KeyUp | AutoKey
-
- // Event codes
-
- NullEvent :== 0;
- MouseDownEvent :== 1;
- MouseUpEvent :== 2;
- KeyDownEvent :== 3;
- KeyUpEvent :== 4;
- AutoKeyEvent :== 5;
- UpdateEvent :== 6;
- DiskEvent :== 7;
- ActivateEvent :== 8;
- NetworkEvent :== 10;
- DriverEvent :== 11;
- OsEvent :== 15;
- HighLevelEvent :== 23;
-
- // Flags for suspend and resume events
-
- ResumeFlag :== 1;
- ConvertClipboardFlag :== 2;
-
- // Message codes for operating-system events
-
- SuspendResumeMessage :== 1; // $01
- MouseMovedMessage :== 250; // $FA
-
- GetNextEvent :: !Int !Toolbox -> (!Bool,!Int,!Int,!Int,!Int,!Int,!Int,!Toolbox);
- GetNextEvent eventMask t
- = (b,what,message,when,(position<<16)>>16,position>>16,modifiers,0);
- {
- (b,what,message,when,position,modifiers)= GetNextEvent2 eventMask t;
- }
-
- GetNextEvent2 :: !Int !Toolbox -> (!Bool,!Int,!Int,!Int,!Int,!Int);
- GetNextEvent2 eventMask t
- = code (eventMask=R18W,t=O4U)(b=D5,what=D4,message=D3,when=D2,position=D1,modifiers=D0){
- instruction 0xA970 || _GetNextEvent
- instruction 0x7A01 || moveq #1,d5
- instruction 0xCA1F || and.b (sp)+,d5
- instruction 0x4485 || neg.l d5
- instruction 0x381F || move (sp)+,d4
- instruction 0x48C4 || ext.l d4
- instruction 0x261F || move.l (sp)+,d3
- instruction 0x241F || move.l (sp)+,d2
- instruction 0x221F || move.l (sp)+,d1
- instruction 0x301F || move (sp)+,d0
- instruction 0x48C0 || ext.l d0
- };
-
- EventAvail :: !Int !Toolbox -> (!Bool,!Int,!Int,!Int,!Int,!Int,!Int,!Toolbox);
- EventAvail eventMask t
- = (b,what,message,when,(position<<16)>>16,position>>16,modifiers,0);
- {
- (b,what,message,when,position,modifiers)= EventAvail2 eventMask t;
- }
-
- EventAvail2 :: !Int !Toolbox -> (!Bool,!Int,!Int,!Int,!Int,!Int);
- EventAvail2 eventMask t = code (eventMask=R18W,t=O4U)(b=D5,what=D4,message=D3,when=D2,position=D1,modifiers=D0){
- instruction 0xA971
- instruction 0x7A01 || moveq #1,d5
- instruction 0xCA1F || and.b (sp)+,d5
- instruction 0x4485 || neg.l d5
- instruction 0x381F || move (sp)+,d4
- instruction 0x48C4 || ext.l d4
- instruction 0x261F || move.l (sp)+,d3
- instruction 0x241F || move.l (sp)+,d2
- instruction 0x221F || move.l (sp)+,d1
- instruction 0x301F || move (sp)+,d0
- instruction 0x48C0 || ext.l d0
- };
-
- WaitNextEvent :: !Int !Int !RgnHandle !Toolbox -> (!Bool,!Int,!Int,!Int,!Int,!Int,!Int,!Toolbox);
- WaitNextEvent eventMask sleep mouseRgn t
- = (b,what,message,when,(position<<16)>>16,position>>16,modifiers,0);
- {
- (b,what,message,when,position,modifiers)= WaitNextEvent2 eventMask sleep mouseRgn t;
- }
-
- WaitNextEvent2 :: !Int !Int !RgnHandle !Toolbox -> (!Bool,!Int,!Int,!Int,!Int,!Int);
- WaitNextEvent2 eventMask sleep mouseRgn t
- = code (eventMask=R18W,sleep=O4L,mouseRgn=L,t=U)(b=D5,what=D4,message=D3,when=D2,position=D1,modifiers=D0){
- instruction 0xA860
- instruction 0x7A01 || moveq #1,d5
- instruction 0xCA1F || and.b (sp)+,d5
- instruction 0x4485 || neg.l d5
- instruction 0x381F || move (sp)+,d4
- instruction 0x48C4 || ext.l d4
- instruction 0x261F || move.l (sp)+,d3
- instruction 0x241F || move.l (sp)+,d2
- instruction 0x221F || move.l (sp)+,d1
- instruction 0x301F || move (sp)+,d0
- instruction 0x48C0 || ext.l d0
- };
-
- TickCount :: !Toolbox -> (!Int,!Toolbox);
- TickCount t = code (t=R4D0)(r=L,z=Z){
- instruction 0xA975
- };
-
- GetMouse :: !Toolbox -> (!Int,!Int,!Toolbox);
- GetMouse tb
- = (h,v,tb1);
- where {
- (v,h,tb1) =: GetMouse1 tb;
- };
-
- GetMouse1 :: !Toolbox -> (!Int,!Int,!Toolbox);
- GetMouse1 t = code (t=R4O0U)(v=W,h=W,z=Z){
- instruction 0xA972
- };
-
- Button :: !Toolbox -> (!Bool,!Toolbox);
- Button t = code (t=R2D0)(b=D1,z=Z){
- instruction 0xA974
- instruction 0x7000 || moveq #0,d0
- instruction 0x101F || move.b (sp)+,d0
- instruction 0x4440 || neg.w d0
- instruction 0x48C0 || ext.l d0
- instruction 0x2200 || move.l d0,d1
- };
-
- StillDown :: !Toolbox -> (!Bool,!Toolbox);
- StillDown t = code (t=R2D0)(b=D1,z=Z){
- instruction 0xA973
- instruction 0x7000 || moveq #0,d0
- instruction 0x101F || move.b (sp)+,d0
- instruction 0x4440 || neg.w d0
- instruction 0x48C0 || ext.l d0
- instruction 0x2200 || move.l d0,d1
- };
-
- WaitMouseUp :: !Toolbox -> (!Bool,!Toolbox);
- WaitMouseUp t = code (t=R2U)(b=D1,z=Z){
- instruction 0xA977
- instruction 0x7000 || moveq #0,d0
- instruction 0x101F || move.b (sp)+,d0
- instruction 0x4440 || neg.w d0
- instruction 0x48C0 || ext.l d0
- instruction 0x2200 || move.l d0,d1
- };
-
- GetKeys :: !Toolbox -> (!Int,!Int,!Int,!Int,!Toolbox);
- GetKeys t =code (t=R16O0U)(k0=L,k1=L,k2=L,k3=L,z=Z){
- instruction 0xA976
- };
-
- HasWaitNextEvent :: !Toolbox -> (!Bool,!Toolbox);
- HasWaitNextEvent tb = (HasWaitNextEvent1 tb, NewToolbox);
-
- HasWaitNextEvent1 :: !Toolbox -> Bool;
- HasWaitNextEvent1 t = code {
- pop_b 1
- .d 0 0
- jsr _has_wait_next_event
- .o 0 1 b
- };
-